/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Manager;

import Global.ConnectDB;
import java.awt.Color;
import java.awt.TextField;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JTextField;

/**
 *
 * @author Administrator
 */
public class Puzzle44 extends javax.swing.JPanel {
    LinkedList<JTextField> listtext;
    ConnectDB connectdb;
    CallableStatement cst,cst2,cst3,cst4,cst5;
    ResultSet rs,rs2,rs3,rs4,rs5;
    CallableStatement cst_update;
    /**
     * Creates new form Puzzle44
     */
    public Puzzle44() {
        initComponents();
        connectdb = new ConnectDB("1433","localhost","mssqlserver","eproject1","sa","123");
        connectdb.openConnection();
        cst_update = null;
            String puz = "{call getAllPuzzle}";
        try{
            
            cst5 = connectdb.cn.prepareCall(puz,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
            rs5 = cst5.executeQuery();
        }catch(SQLException ex){
            ex.printStackTrace();
        
        editListtext(false);  
        //loadQuestion();
        }
    }
    
    public void insertQuestion(){
        String ques = "{call getAllQuestions}";
        try{
            cst = connectdb.cn.prepareCall(ques, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); 
            rs = cst.executeQuery();
            
        }catch(SQLException ex){
            ex.printStackTrace();
        }
}
    public void addQuestion(){
        
    }
   
    public void addAnswer(){
        String ans = "{call getAllAnswer}";
        
        try{
            cst2 = connectdb.cn.prepareCall(ans, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
            rs2 =cst2.executeQuery();
            
            
        }catch(SQLException ex){
            ex.printStackTrace();
           }
    }
    public void callRow(){
        String row = "{call getRow}";
        try {
            
            cst4 = connectdb.cn.prepareCall(row, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
            rs4 = cst4.executeQuery();
            
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    public void callCol(){
        String col = "{call getCol}";
        try{
            cst3 = connectdb.cn.prepareCall(col,ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
            rs4 = cst4.executeQuery();
        }catch(SQLException e){
            e.printStackTrace();
        }
    }
   
    public void even_key(){
        final String regxs="\\d+$";
        Thread thread =new Thread(new Runnable() {

            public void run() {
                for(final JTextField t: list_4x4){
                    t.setEditable(false);
              t.addKeyListener(new KeyListener() {

                public void keyTyped(KeyEvent e) {
                      
                }

                public void keyPressed(KeyEvent e) {

                    if(e.getKeyChar()=='*'){
                        t.setForeground(new java.awt.Color(204, 0, 0));
                        t.setBackground(new java.awt.Color(204, 204, 204));
                    }
                    else{
                        t.setForeground(new java.awt.Color(0, 0, 255));
                        t.setBackground(Color.WHITE);
                    }
                }

                public void keyReleased(KeyEvent e) {
                            @SuppressWarnings("static-access")
                     String a=e.getKeyText(e.getKeyCode());
                        if(e.getKeyChar()>='A'&&e.getKeyChar()<='Z'||e.getKeyChar()>='a'&&e.getKeyChar()<='z'||e.getKeyChar()=='*'||a.matches(regxs)){
                                 t.setText((""+e.getKeyChar()).toUpperCase());
                        }

                }
            });
          }
            }
        });
        thread.start();
        try {
            thread.join();
        } catch (InterruptedException ex) {
           
        }
        final String regx="\\D+$";
    }
    
    public void editListtext(boolean ok){
        txf1_1.setEditable(ok);
        txf1_2.setEditable(ok);
        txf1_3.setEditable(ok);
        txf1_4.setEditable(ok);
        txf2_1.setEditable(ok);
        txf2_2.setEditable(ok);
        txf2_3.setEditable(ok);
        txf2_4.setEditable(ok);
        txf3_1.setEditable(ok);
        txf3_2.setEditable(ok);
        txf3_3.setEditable(ok);
        txf3_4.setEditable(ok);
        txf4_1.setEditable(ok);
        txf4_2.setEditable(ok);
        txf4_3.setEditable(ok);
        txf4_4.setEditable(ok);
    }
    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        panel1 = new java.awt.Panel();
        txf1_1 = new javax.swing.JTextField();
        txf1_2 = new javax.swing.JTextField();
        txf1_3 = new javax.swing.JTextField();
        txf1_4 = new javax.swing.JTextField();
        txf2_1 = new javax.swing.JTextField();
        txf2_2 = new javax.swing.JTextField();
        txf2_3 = new javax.swing.JTextField();
        txf2_4 = new javax.swing.JTextField();
        txf3_1 = new javax.swing.JTextField();
        txf3_2 = new javax.swing.JTextField();
        txf3_3 = new javax.swing.JTextField();
        txf3_4 = new javax.swing.JTextField();
        txf4_1 = new javax.swing.JTextField();
        txf4_2 = new javax.swing.JTextField();
        txf4_3 = new javax.swing.JTextField();
        txf4_4 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        cbb_row = new javax.swing.JComboBox();
        cbb_col = new javax.swing.JComboBox();
        btSaveA = new javax.swing.JButton();
        btSaveB = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        btCreate = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tfB = new javax.swing.JTextArea();
        jScrollPane2 = new javax.swing.JScrollPane();
        tfA = new javax.swing.JTextArea();
        txfPName = new javax.swing.JTextField();

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 36)); // NOI18N
        jLabel1.setText("Puzzle 4x4");

        panel1.setLayout(new java.awt.GridLayout(4, 4, 1, 1));

        txf1_1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txf1_1ActionPerformed(evt);
            }
        });
        panel1.add(txf1_1);
        panel1.add(txf1_2);
        panel1.add(txf1_3);
        panel1.add(txf1_4);
        panel1.add(txf2_1);
        panel1.add(txf2_2);
        panel1.add(txf2_3);
        panel1.add(txf2_4);
        panel1.add(txf3_1);
        panel1.add(txf3_2);
        panel1.add(txf3_3);
        panel1.add(txf3_4);
        panel1.add(txf4_1);
        panel1.add(txf4_2);
        panel1.add(txf4_3);
        panel1.add(txf4_4);

        jButton1.setText("New");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Edit");

        jButton3.setText("Delete");

        jLabel3.setText("Puzzle Name:");

        jLabel4.setText("Accross Question:");

        jLabel5.setText("Down Question:");

        cbb_row.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbb_row.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbb_rowActionPerformed(evt);
            }
        });

        cbb_col.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        btSaveA.setText("OK");
        btSaveA.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btSaveAMouseClicked(evt);
            }
        });
        btSaveA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSaveAActionPerformed(evt);
            }
        });

        btSaveB.setText("OK");
        btSaveB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btSaveBActionPerformed(evt);
            }
        });

        jLabel6.setText("1");

        jLabel7.setText("2");

        jLabel8.setText("3");

        jLabel9.setText("4");

        jLabel10.setText("1");

        jLabel11.setText("2");

        jLabel12.setText("3");

        jLabel13.setText("4");

        btCreate.setText("Create");
        btCreate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCreateActionPerformed(evt);
            }
        });

        tfB.setColumns(20);
        tfB.setRows(5);
        jScrollPane1.setViewportView(tfB);

        tfA.setColumns(20);
        tfA.setRows(5);
        jScrollPane2.setViewportView(tfA);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(69, 69, 69)
                                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(59, 59, 59)
                                .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(56, 56, 56)
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(68, 68, 68))
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(panel1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(42, 42, 42))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jButton3)
                                .addGap(111, 111, 111)))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel5)
                                        .addGap(18, 18, 18)
                                        .addComponent(cbb_col, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(cbb_row, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btSaveB)
                                    .addComponent(btSaveA)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txfPName, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE))
                            .addComponent(btCreate)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 274, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 95, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(72, 72, 72)
                        .addComponent(jLabel10)
                        .addGap(51, 51, 51)
                        .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(44, 44, 44)
                        .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(48, 48, 48)
                        .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(12, 12, 12)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(panel1, javax.swing.GroupLayout.PREFERRED_SIZE, 275, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(txfPName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel3))
                                        .addGap(28, 28, 28)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(cbb_row, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(btSaveA)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(14, 14, 14)
                                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(18, 18, 18)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(24, 24, 24)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel5)
                                    .addComponent(cbb_col, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(btSaveB))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btCreate)
                    .addComponent(jButton3)
                    .addComponent(jButton2)
                    .addComponent(jButton1))
                .addContainerGap(116, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void txf1_1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txf1_1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txf1_1ActionPerformed

    private void btSaveAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSaveAActionPerformed
        
        insertQuestion();
        addAnswer();
        callRow();
        StringBuilder sb = new StringBuilder("");
        if(cbb_row.getSelectedItem().equals("Item 1")){
        sb.append(txf1_1.getText()).append(txf1_2.getText()).append(txf1_3.getText()).append(txf1_4.getText());
        }
        else if(cbb_row.getSelectedItem().equals("Item 2")){
        sb.append(txf2_1.getText()).append(txf2_2.getText()).append(txf2_3.getText()).append(txf2_4.getText());
        }
        else if(cbb_row.getSelectedItem().equals("Item 3")){
        sb.append(txf3_1.getText()).append(txf3_2.getText()).append(txf3_3.getText()).append(txf3_4.getText());
        }
        else if(cbb_row.getSelectedItem().equals("Item 4")){
        sb.append(txf4_1.getText()).append(txf4_2.getText()).append(txf4_3.getText()).append(txf4_4.getText());
        }
        try{
            rs.moveToInsertRow();        
            rs.updateString(2, tfA.getText().trim());
            rs.insertRow();
            rs.moveToCurrentRow();
            rs.last();
            rs2.moveToInsertRow(); 
            rs2.updateInt(1, rs.getInt(1));
            rs2.updateString(2, sb.toString().trim());
            rs2.updateInt(3, 1);
            rs2.insertRow();
            rs2.moveToCurrentRow();
            rs4.moveToInsertRow();
            rs5.last();
            rs4.updateInt(2, rs5.getInt(1));
            rs4.updateString(3, cbb_row.getSelectedItem().toString());
            rs4.updateInt(4, rs.getInt(1));
            rs4.insertRow();
            rs4.moveToCurrentRow();
        }catch (SQLException e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_btSaveAActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        editListtext(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void cbb_rowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbb_rowActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbb_rowActionPerformed

    private void btCreateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCreateActionPerformed
        // TODO add your handling code here:
        
        try{
            rs5.moveToInsertRow();
            rs5.updateInt(2, 1);
            rs5.updateString(3, txfPName.getText().trim());
            rs5.insertRow();
            rs5.moveToCurrentRow();
        }catch(SQLException ex){
            ex.printStackTrace();
        }
    }//GEN-LAST:event_btCreateActionPerformed
    public void loadtoPuzz()
    {
        txf1_1.setText("");
        
    }
    private void btSaveAMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btSaveAMouseClicked
            
    }//GEN-LAST:event_btSaveAMouseClicked

    private void btSaveBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btSaveBActionPerformed
        // TODO add your handling code here:
        insertQuestion();
        addAnswer();
        callCol();
        StringBuilder sb = new StringBuilder("");
        if(cbb_col.getSelectedItem().equals("Item 1")){
        sb.append(txf1_1.getText()).append(txf2_1.getText()).append(txf3_1.getText()).append(txf4_1.getText());
        }
        else if(cbb_col.getSelectedItem().equals("Item 2")){
        sb.append(txf1_2.getText()).append(txf2_2.getText()).append(txf3_2.getText()).append(txf4_2.getText());
        }
        else if(cbb_col.getSelectedItem().equals("Item 3")){
        sb.append(txf1_3.getText()).append(txf2_3.getText()).append(txf3_3.getText()).append(txf4_3.getText());
        }
        else if(cbb_col.getSelectedItem().equals("Item 4")){
        sb.append(txf1_4.getText()).append(txf2_4.getText()).append(txf3_4.getText()).append(txf4_4.getText());
        }
        try{
            rs.moveToInsertRow();        
            rs.updateString(2, tfA.getText().trim());
            rs.insertRow();
            rs.moveToCurrentRow();
            rs.last();
            rs2.moveToInsertRow(); 
            rs2.updateInt(1, rs.getInt(1));
            rs2.updateString(2, sb.toString().trim());
            rs2.updateInt(3, 1);
            rs2.insertRow();
            rs2.moveToCurrentRow();
            rs3.moveToInsertRow();
            rs5.last();
            rs3.updateInt(2, rs5.getInt(1));
            rs3.updateString(3, cbb_col.getSelectedItem().toString());
            rs3.updateInt(4, rs.getInt(1));
            rs3.insertRow();
            rs3.moveToCurrentRow();
        }catch (SQLException e) {
            e.printStackTrace();
        }
    }//GEN-LAST:event_btSaveBActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCreate;
    private javax.swing.JButton btSaveA;
    private javax.swing.JButton btSaveB;
    private javax.swing.JComboBox cbb_col;
    private javax.swing.JComboBox cbb_row;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private java.awt.Panel panel1;
    private javax.swing.JTextArea tfA;
    private javax.swing.JTextArea tfB;
    private javax.swing.JTextField txf1_1;
    private javax.swing.JTextField txf1_2;
    private javax.swing.JTextField txf1_3;
    private javax.swing.JTextField txf1_4;
    private javax.swing.JTextField txf2_1;
    private javax.swing.JTextField txf2_2;
    private javax.swing.JTextField txf2_3;
    private javax.swing.JTextField txf2_4;
    private javax.swing.JTextField txf3_1;
    private javax.swing.JTextField txf3_2;
    private javax.swing.JTextField txf3_3;
    private javax.swing.JTextField txf3_4;
    private javax.swing.JTextField txf4_1;
    private javax.swing.JTextField txf4_2;
    private javax.swing.JTextField txf4_3;
    private javax.swing.JTextField txf4_4;
    private javax.swing.JTextField txfPName;
    // End of variables declaration//GEN-END:variables
}
